package thread;

class PrintTask implements Runnable{
    public void run() {
        for (int i = 0; i < 1000; i++){
            System.out.println(Thread.currentThread().getName() + ":" + i);
            try{
                Thread.sleep(1000);
            }catch (InterruptedException e){}
        }
    }
}
public class ThreadPriorityDemo01 {
    public static void main(String[] args) {
        //创建三个任务，三个线程，并指定线程的名字，然后设置线程优先级，再启动线程
        Thread t1 = new Thread(new PrintTask() ,"Thread-A");
        Thread t2 = new Thread(new PrintTask() ,"Thread-B");
        Thread t3 = new Thread(new PrintTask() ,"Thread-C");
        //设置优先级
        t1.setPriority(Thread.MIN_PRIORITY);
        t2.setPriority(Thread.NORM_PRIORITY);
        t3.setPriority(Thread.MAX_PRIORITY);
        t1.start();
        t2.start();
        t3.start();

    }
}
